package com.haoshuang.zhouzhoubang.ui.vm

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.Data2
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class SharingServiceViewModel : BaseViewModel() {
  val getLogistics = StatefulMutableLiveData<Data2>()
      fun getLogistics(vararg params: Pair<String, Any?>) {
          rxLifeScope.launch {
              request<Data2>("/api/store_api/get_spread_product_list", *params,
                  onStart = {
                      getLogistics.value = StateData.Loading
                  },
                  onError = { code, msg ->
                      getLogistics.value = StateData.Error(code, msg)
                  }, onSuccess = {
                      getLogistics.value = StateData.Success(it)
                  })
          }
      }
}